<?php
$this->LoadHelper('ApiHelper');
$ApiHelper = new ApiHelper();

$this->LoadHelper('MemberHelper');
$MemberHelper = new MemberHelper();

$this->LoadHelper('BranchHelper');
$BranchHelper = new BranchHelper();

$check = $ApiHelper->tokenCheck($this->Param);
if(!$check['success']) ErrorMsg::ApiMsg($check['msg'], $check['code']);

switch($this->Param['option']){
    case 'brmember'://获取用户同网点用户
        $member = $MemberHelper->getMember($this->Param['uid']);
        $where['`u_status` = ?'] = 'ok';
        if($member['u_dp_type'] == 'rg'){
            $branch = $BranchHelper->branchRow(array('`br_status` = ?' => 'ok', '`br_rgid` = ?' => $member['u_dp_id']));
            $br_id = array(0);
            if(!empty($branch)) foreach($branch as $k=>$v){
                $br_id[] = $v['br_id'];
            }
            $where['`u_dp_type` = ?'] = 'dot';
            $where['`u_dp_id` IN(?)'] = $br_id;
        }  else {
            $where['`u_dp_type` = ?'] = $member['u_dp_type'];
            $where['`u_dp_id` = ?'] = $member['u_dp_id'];
        }
        $data = $MemberHelper->getMemberAll($where);
        if(!empty($data)) foreach($data as $k=>$v){
            $json_data[] = array(
                'u_id' => $v['u_id'],
                'u_realname' => $v['u_realname']
            );
        }
        ErrorMsg::ApiMsg('请求成功', 0 , $json_data);
        break;
}